package com.hy.${packageCode}.shared.distribute.map;

import com.hy.${packageCode}.shared.distribute.lock.DelegatingLock;
import com.hy.${packageCode}.shared.distribute.lock.DistLock;
import com.hy.${packageCode}.shared.distribute.lock.DistReadWriteLock;
import com.hy.${packageCode}.shared.distribute.lock.DelegatingLock;
import com.hy.${packageCode}.shared.distribute.lock.DelegatingReadWriteLock;
import com.hy.${packageCode}.shared.distribute.lock.DistLock;
import com.hy.${packageCode}.shared.distribute.lock.DistReadWriteLock;
import com.hy.${packageCode}.shared.distribute.lock.DelegatingLock;
import com.hy.${packageCode}.shared.distribute.lock.DistLock;
import com.hy.${packageCode}.shared.distribute.lock.DistReadWriteLock;
import org.redisson.api.RMap;

/**
 * 基于redisson(redis) RMAP 实现的分布式Java Map
 *
 * @param <K> Map Key 类型
 * @param <V> Map Value 类型
 */
public class DistributionMap<K, V> extends StandaloneMap<K, V> implements DistMap<K, V> {
    private final RMap<K, V> delegatingMap;

    public DistributionMap(RMap<K, V> delegatingMap) {
        super(delegatingMap);
        this.delegatingMap = delegatingMap;
    }

    @Override
    public DistLock getLock(K key) {
        return new DelegatingLock(delegatingMap.getLock(key));
    }

    @Override
    public DistReadWriteLock getReadWriteLock(K key) {
        return new DelegatingReadWriteLock(delegatingMap.getReadWriteLock(key));
    }

    @Override
    public boolean fastPut(K key, V value) {
        return delegatingMap.fastPut(key, value);
    }

    @Override
    public boolean fastPutIfAbsent(K key, V value) {
        return delegatingMap.fastPutIfAbsent(key, value);
    }

    @Override
    public void fastRemove(K key) {
        delegatingMap.fastRemove(key);
    }
}
